package com.api.shopapi.mapper;

import com.api.shopapi.entity.UserDevice;
import com.api.shopapi.entity.dto.UserDeviceDTO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface UserDeviceMapper {

    @Insert("insert into  user_device " +
            "(" +
            "UserDeviceCode, " +
            "UserCode, " +
            "XiaoLe, " +
            "ToGWatch, " +
            "YJSBJian, " +
            "YJGateway," +
            "LXXueYaJi," +
            "QZXueTangYi " +
            ") " +
            "VALUES " +
            "(" +
            "#{userDevice.UserDeviceCode} ," +
            "#{userDevice.UserCode} ," +
            "#{userDevice.XiaoLe} ," +
            "#{userDevice.ToGWatch}, " +
            "#{userDevice.YJSBJian}, " +
            "#{userDevice.YJGateway}," +
            "#{userDevice.LXXueYaJi}," +
            "#{userDevice.QZXueTangYi} " +
            ") ")
    int insert(@Param("userDevice") UserDevice userDevice);


    @Update("update user_device set " +
            "UserCode=#{userDevice.UserCode} ," +
            "XiaoLe=#{userDevice.XiaoLe} ," +
            "ToGWatch=#{userDevice.ToGWatch}, " +
            "YJSBJian=#{userDevice.YJSBJian}, " +
            "YJGateway=#{userDevice.YJGateway}, " +
            "LXXueYaJi=#{userDevice.LXXueYaJi}, " +
            "QZXueTangYi=#{userDevice.QZXueTangYi} " +
            "where " +
            "UserDeviceCode=#{userDevice.UserDeviceCode}  ")
    int update(@Param("userDevice") UserDevice userDevice);



    @Select("select * from user_device where UserDeviceCode=#{userDeviceCode} limit 1 ")
    UserDevice getByUserDeviceCode(@Param("userDeviceCode") String userDeviceCode);


    @Select("select  * from user_device where UserCode=#{userCode}  limit 1 ")
    UserDevice getByUserCode(@Param("userCode") String userCode);

    @Select("select * from user_device  where UserCode=#{userCode}  limit 1 ")
    UserDeviceDTO getForUserDeviceDTO(@Param("userCode") String userCode);





}
